package nu.member.model;

import java.util.List;

import nu.board.model.GroupVO;
import nu.board.model.MemberGroupVO;

import org.mybatis.spring.SqlSessionTemplate;

public class MemberDaoImpl implements MemberDao{
	private SqlSessionTemplate sqlSessionTemplate;
	public MemberDaoImpl(SqlSessionTemplate sqlSessionTemplate){
		this.sqlSessionTemplate=sqlSessionTemplate;
	}
	@Override
	public MemberVO selectLogin(MemberVO vo) throws Exception {
		return sqlSessionTemplate.selectOne("member.selectLogin", vo);
	}
	@Override
	public int insertMember(MemberVO vo) throws Exception {
		return sqlSessionTemplate.insert("member.insertMember", vo);
	}
	@Override
	public MemberVO selectMemberById(String id) throws Exception {
		return sqlSessionTemplate.selectOne("member.selectMemberById", id);
	}
	@Override
	public int updateMember(MemberVO vo) throws Exception {
		return sqlSessionTemplate.update("member.updateMember", vo);
	}
	@Override
	public int selectCountById(String id) throws Exception {
		return sqlSessionTemplate.selectOne("member.selectCountById", id);
	}
	@Override
	public List<GroupVO> selectGroupListByMemberId(String id) throws Exception {
		return sqlSessionTemplate.selectList("board.selectGroupListByMemberId",id);
	}
	@Override
	public int insertMemberToGroup(MemberGroupVO mgvo) throws Exception {
		return sqlSessionTemplate.insert("board.insertMemberToGroup", mgvo);
	}
	@Override
	public int updateGroupCurrent(int group_id) throws Exception {
		return sqlSessionTemplate.update("board.updateGroupCurrent",group_id);
	}
	
	/**
	 * Study Nick 업데이트
	 */
	@Override
	public void updateStudyNickName(MemberVO vo) throws Exception {
		sqlSessionTemplate.update("member.updateStudyNickName", vo);
	}
	/**
	 * Sports Nick 업데이트
	 */
	@Override
	public void updateSportsNickName(MemberVO vo) throws Exception {
		sqlSessionTemplate.update("member.updateSportsNickName", vo);
	}
	/**
	 * Smoking Nick 업데이트
	 */
	@Override
	public void updateSmokingNickName(MemberVO vo) throws Exception {
		sqlSessionTemplate.update("member.updateSmokingNickName", vo);
	}
	/**
	 * Finance Nick 업데이트
	 */
	@Override
	public void updateFinanceNickName(MemberVO vo) throws Exception {
		sqlSessionTemplate.update("member.updateFinanceNickName", vo);
	}
	/**
	 * Living Nick 업데이트
	 */
	@Override
	public void updateLivingNickName(MemberVO vo) throws Exception {
		sqlSessionTemplate.update("member.updateLivingNickName", vo);
	}
	
	/**
	 * Member Info 를 모조리 싹 다 가져오는 메소드
	 */
	@Override
	public MemberVO selectMemberInfo(MemberVO vo) throws Exception {
		return sqlSessionTemplate.selectOne("member.selectMemberInfo", vo);
	}
	
	/**
	  * 인증눌러줬을때 포인트가 플러스되는곳...
	  */
	@Override
	public void plusStudyPointById(String writer) throws Exception {
		sqlSessionTemplate.update("member.plusStudyPointById", writer);
	}

	@Override
	public void plusSportsPointById(String writer) throws Exception {
		sqlSessionTemplate.update("member.plusSportsPointById", writer);
	}

	@Override
	public void plusSmokingPointById(String writer) throws Exception {
		sqlSessionTemplate.update("member.plusSmokingPointById", writer);
	}

	@Override
	public void plusFinancePointById(String writer) throws Exception {
		sqlSessionTemplate.update("member.plusFinancePointById", writer);
	}

	@Override
	public void plusLivingPointById(String writer) throws Exception {
		sqlSessionTemplate.update("member.plusLivingPointById", writer);
	}
	@Override
	public String selectNickContent(String nick, String type) throws Exception {
		NickVO nvo = new NickVO();
		nvo.setFinance_nick(nick);
		nvo.setLiving_nick(type);
		return sqlSessionTemplate.selectOne("member.selectNickContent", nvo);
	}
	@Override
	 public String selectSavefilenameById(String id) throws Exception {
	  return sqlSessionTemplate.selectOne("member.selectSavefilenameById", id);
	 }
}
